package io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 简易记事本
 *
 */
public class Text2 {
    public static void main(String[] args) throws IOException {
        //先使用file来创建文件
        File file =new File("note.txt");
        FileOutputStream fos =new FileOutputStream(file);
        OutputStreamWriter osw =new OutputStreamWriter(fos,StandardCharsets.UTF_8);
        file.createNewFile();
        //使用扫描仪来接收数据
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入你要记录的内容：");
        System.out.println("输入exit可以退出程序");
        while (true){
            String next = sc.next();
            if ("exit".equalsIgnoreCase(next)){
                break;
            }
            osw.write(next);
            System.out.println("继续输入");
        }
        osw.close();
    }
}
